<template>
	<view class="answeredcard-content" @click="goquestiondetails(answereddata.id)">
		<view class="answeredcard-content-header">
			<view class="content-header-nav" :class="answereddata.content==''?'header-nav-bottom':''">
				<span>{{answereddata.title}}</span>
				<img :src="queryIconImage('modelone1')" alt="" class="header-nav-img">
				<img :src="queryIconImage('modelone1')" alt="" class="header-nav-img">

			</view>
			<view class="content-header-text" v-if="answereddata.content">
				<span>{{answereddata.content}}</span>
			</view>
		</view>

		<u-popup :safe-area-inset-bottom="false" mode="center" :round="20" :show="showtwo" :disabled="true">
			<view class="popularlogin">
				<img :src="queryIconImage('weixinlogo1')" alt="" style="width: 60rpx;height: 60rpx;">
				<p class="popularlogin-text">登录后查看</p>
				<view class="popularlogin-btn">
					<view class="popularlogin-btn-left" @click="loginsubmit">
						<span>授权登录</span>
					</view>
					<view class="popularlogin-btn-left" style="background: #999999;" @click="cancellationbtn">
						<span>取消</span>
					</view>
				</view>
			</view>
		</u-popup>

		<view class="answeredcard-content-bottom">
			<view class="content-bottom-body">
				<view class="bottom-body-left">
					<view class="body-left-img">
						<img :src="answereddata.user?.avatar?.url?answereddata.user?.avatar?.url:queryIconImage('modelone1')"
							alt="" class="left-imgss">
					</view>
					<span class="body-left-name">{{answereddata.user?.nickname}}</span>
					<span>的提问</span>
					<span class="body-left-text"
						v-if="answereddata.price_cny&&answereddata.type=='悬赏提问'">悬赏{{answereddata.price_cny}}元</span>
				</view>
				<view class="bottom-body-right" @click.prevent.stop="goquestiondetailschaild(answereddata.id)">
					<span>写回答</span>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		name: "answeredCard",
		props: {
			answereddata: {
				type: Object,
				default: () => {}
			}
		},
		data() {
			return {
				showtwo: false,
			};
		},
		computed: {
			...mapState({
				headericon: state => state.remote?.headericon?.data_list ?? [],
			})
		},
		methods: {
			loginsubmit() {
				uni.navigateTo({
					url: `/pages/login/login`
				})
				this.showtwo = false
			},
			cancellationbtn() {
				this.showtwo = false

			},
			queryIconImage(label, key = "headericon") {
				return this[key]?.find(res => res?.label == label)?.img?.url;
			},
			goquestiondetails(data) {
				let usercoundId = uni.getStorageSync('userInfo').id
				if (usercoundId) {
					uni.navigateTo({
						url: `/pages_a/questiondetails/questiondetails?ansereid=${data}`
					})
				} else {
					this.showtwo = true
				}


			},
			goquestiondetailschaild(val) {
				let usercoundId = uni.getStorageSync('userInfo').id
				if (usercoundId) {
					uni.navigateTo({
						url: `/pages_a/questiondetails/questiondetails?id=${val}`
					})
				} else {
					this.showtwo = true
				}

			}
		}
	}
</script>

<style lang="scss">
	.answeredcard-content {
		width: 100%;
		background-color: #fff;
		border-radius: 15px;
		margin-bottom: 25rpx;

		.popularlogin {
			width: 595rpx;
			height: 370rpx;
			background: #FFFFFF;
			box-sizing: border-box;
			padding: 20rpx 0 40rpx 0;
			border-radius: 15rpx 15rpx 15rpx 15rpx;
			display: flex;
			flex-direction: column;
			align-items: center;

			.popularlogin-text {
				font-size: 32rpx;
				font-family: Alibaba PuHuiTi 2.0-65 Medium, Alibaba PuHuiTi 20;
				font-weight: 600;
				color: rgba(0, 0, 0, 0.8);
				line-height: 40rpx;
				margin: 12rpx 0 128rpx 0
			}

			.popularlogin-btn {
				display: flex;
				justify-content: space-between;
				width: 100%;
				box-sizing: border-box;
				padding: 0 65rpx;

				.popularlogin-btn-left {
					width: 215rpx;
					height: 70rpx;
					background: #26C789;
					border-radius: 80rpx 80rpx 80rpx 80rpx;
					text-align: center;
					font-size: 24rpx;
					font-family: Alibaba PuHuiTi 2.0-85 Bold, Alibaba PuHuiTi 20;
					font-weight: 700;
					color: #FFFFFF;
					line-height: 70rpx;
				}
			}
		}

		.answeredcard-content-header {
			border-bottom: 2rpx solid #ccc;
			box-sizing: border-box;
			padding: 26rpx 28rpx 0 20rpx;


			.header-nav-bottom {
				margin-bottom: 40rpx !important;
			}

			.content-header-nav {
				font-size: 30rpx;
				font-family: Alibaba PuHuiTi 2.0-65 Medium, Alibaba PuHuiTi 20;
				font-weight: 500;
				color: #4A4A4A;
				line-height: 42rpx;
				display: flex;
				align-items: center;
				margin-bottom: 22rpx;

				.header-nav-img {
					width: 32rpx;
					height: 32rpx;
					border-radius: 8rpx 8rpx 8rpx 8rpx;
					margin-left: 15rpx;
				}
			}

			.content-header-text {
				font-size: 30rpx;
				font-family: Source Han Sans CN-Regular, Source Han Sans CN;
				font-weight: 400;
				color: #999999;
				line-height: 42rpx;
				margin-bottom: 32rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 3;
				-webkit-box-orient: vertical;
			}
		}

		.answeredcard-content-bottom {
			box-sizing: border-box;
			padding: 22rpx 28rpx 30rpx 20rpx;
			width: 100%;


			.content-bottom-body {
				display: flex;
				justify-content: space-between;
				align-items: center;
				width: 100%;
				height: 60rpx;

				.bottom-body-right {
					width: 160rpx;
					height: 60rpx;
					background: #F09500;
					border-radius: 15rpx 15rpx 15rpx 15rpx;
					text-align: center;
					font-size: 30rpx;
					font-family: Source Han Sans CN-Bold, Source Han Sans CN;
					font-weight: 700;
					color: #FFFFFF;
					line-height: 60rpx;
				}

				.bottom-body-left {
					display: flex;
					font-size: 20rpx;
					font-family: Source Han Sans CN-Bold, Source Han Sans CN;
					font-weight: 700;
					color: #9E9E9E;
					line-height: 42rpx;

					.body-left-img {
						width: 50rpx;
						height: 50rpx;
						border-radius: 50%;
						display: flex;
						align-items: center;
						justify-content: center;
						overflow: hidden;
						margin-right: 15rpx;

						.left-imgss {
							width: 50rpx;
							height: 50rpx;

						}
					}

					.body-left-name {
						margin-right: 20rpx;
						font-size: 26rpx;
						font-family: Source Han Sans CN-Bold, Source Han Sans CN;
						font-weight: 700;
						color: #567895;
						line-height: 42rpx;
					}

					.body-left-text {
						margin-left: 15rpx;
						font-size: 24rpx;
						font-family: Source Han Sans CN-Bold, Source Han Sans CN;
						font-weight: 700;
						color: #F09500;
						line-height: 45rpx;
					}
				}
			}

		}
	}
</style>